package com.ljy.tkmodel.controller;


import com.ljy.tkmodel.entity.LjyZhuanshuoChapter;
import com.ljy.tkmodel.entity.LjyZhuanshuoQuestion;
import com.ljy.tkmodel.entity.vo.LjyEasyZhuanshuoChapterVO;
import com.ljy.tkmodel.service.LjyZhuanshuoQuestionService;
import com.ljy.tkuser.entity.LjyBigUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;

/**
 * <p>
 * 专硕题库 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2022-01-04
 */
@RestController
@RequestMapping("/ljy-zhuanshuo-question")
public class LjyZhuanshuoQuestionController {
    @Autowired
    private LjyZhuanshuoQuestionService  questionService;
    @GetMapping("getHomeList")
    public ArrayList<LjyZhuanshuoChapter> getHomeList(HttpSession session) {
        LjyBigUser loginUser = (LjyBigUser)session.getAttribute("loginUser");
        ArrayList<LjyZhuanshuoChapter> list = questionService.getHomeAll(loginUser.getUserId());
        return list;
    }
    //用java逻辑封装数据
    @GetMapping("getTkAll")
    public ArrayList<LjyZhuanshuoChapter> getTkChapterAll(HttpSession session){
        long l = System.currentTimeMillis();
        ArrayList<LjyZhuanshuoChapter> tkChapterAll = questionService.getTKChapterAll(session);
        long l1 = System.currentTimeMillis();
        System.out.println("计算时间："+(l1-l));
        return tkChapterAll;
    }
    //用sql语句组装
    @GetMapping("getEasyAll")
    public ArrayList<LjyEasyZhuanshuoChapterVO> getEasyAll(){
        return questionService.getEasyChapterAll();
    }

    //查询全部题
    @GetMapping("getQuestionAll")
    public ArrayList<LjyZhuanshuoQuestion> getQuestionAll(){
        return questionService.getQuestionAll();
    }

    //查询全部章节
    @GetMapping("getChapterAll")
    public ArrayList<LjyZhuanshuoChapter> getChapterAll(){
        return questionService.getChapterAll();
    }

    //模拟用户查看章节下的题
    @GetMapping("getUserChapterTOQuestion")
    public ArrayList<LjyZhuanshuoQuestion> getUserChapterTOQuestion(){
            return  questionService.getUserChapterTOQuestion();
    }

    @GetMapping("AsyncQuery")
    public ArrayList<LjyZhuanshuoChapter> AsyncQuery(){
        return questionService.AsyncQueryChapter();
    }
}

